package com.neomanager.bbs.dao;

import java.util.ArrayList;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class CombineDao extends SqlMapClientDaoSupport
{
	public Logger logger = Logger.getLogger(this.getClass());

	/**
	 * 통합게시판 정보
	 */
	@SuppressWarnings("unchecked")
	public Map<String, Object> selectCombineBBSInfo(String bbs_id) throws DataAccessException
	{
		logger.info("통합게시판정보 DAO");
		return (Map<String, Object>)getSqlMapClientTemplate().queryForObject("combine.selectCombineInfo", bbs_id);
	}
	
	/**
	 * 통합게시판 목록[공지]
	 */
	public ArrayList<Map<String, Object>> selectCombineBBSList1(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판목록[공지] DAO");
		@SuppressWarnings("unchecked")
		ArrayList<Map<String, Object>> rslist = (ArrayList<Map<String, Object>>) getSqlMapClientTemplate().queryForList("combine.selectCombineBBSInfo1", param);
        return rslist;
	}

	/**
	 * 통합게시판 목록
	 */
	public ArrayList<Map<String, Object>> selectCombineBBSList2(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판목록 DAO");
		@SuppressWarnings("unchecked")
		ArrayList<Map<String, Object>> rslist = (ArrayList<Map<String, Object>>) getSqlMapClientTemplate().queryForList("combine.selectCombineBBSInfo2", param);
        return rslist;
	}
	
	/**
	 * 통합게시판 등록
	 */
	public void insertCombineInfo(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판 등록 DAO");
		getSqlMapClientTemplate().insert("combine.insertCombineInfo", param);
        return;
	}
	
	/**
	 * 통합게시판 게시물 조회
	 */
	@SuppressWarnings("unchecked")
	public Map<String, Object> selectCombineBBSView(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판 게시물 조회 정보 DAO");
		return (Map<String, Object>)getSqlMapClientTemplate().queryForObject("combine.selectCombineView", param);
	}
	
	/**
	 * 통합게시판 게시물 수정
	 */
	public void updateCombineInfo(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판 게시물 수정 DAO");
		getSqlMapClientTemplate().insert("combine.updateCombineInfo", param);
        return;
	}
	
	/**
	 * 통합게시판 게시물 조회수 증가
	 */
	public void updateCombineHit(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판 게시물 조회수 증가 DAO");
		getSqlMapClientTemplate().insert("combine.updateCombineHit", param);
        return;
	}

	/**
	 * 통합게시판 답글 여부
	 */
	public void updateCombineEtc(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판 답변 여부 체크 DAO");
		getSqlMapClientTemplate().update("combine.updateCombineEtc", param);
		return;
	}
	
	/**
	 * 통합게시판 게시물 삭제
	 */
	public void deleteCombineInfo(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판 게시물 삭제 DAO");
		getSqlMapClientTemplate().insert("combine.deleteCombineInfo", param);
        return;
	}
	
	/**
	 * 통합게시판 답글관련 STEP 수정
	 */
	public void updateCombineStep(Map<String, Object> param) throws DataAccessException
	{
		logger.info("통합게시판 답글관련 STEP 수정 DAO");
		getSqlMapClientTemplate().insert("combine.updateCombineStep", param);
        return;
	}
}
